import { WeaForm } from 'comsMobx';
import { observable, action } from 'mobx';
import objectAssign from 'object-assign';

import { getRemindData,doRemind } from '../apis/remindSetApi';

export default class RemindSetStore {

    @observable form = new WeaForm();
    @observable condition = [];
    params = {};
    callBackActions;

    constructor(){
        this.getRemindData = this.getRemindData;
        this.doRemind = this.doRemind;
        this.setParams = this.setParams;
    }
    /**
     * 初始数据
     */
    @action getRemindData = () => {
        getRemindData(this.params).then((reVal)=>{
            this.condition = reVal.condition;
            this.form.initFormFields(reVal.condition);
        });
    }

    /**
     * 提醒
     */
    @action doRemind = (para={}) => {
        doRemind(objectAssign({},para,this.params)).then((reVal)=>{
            this.callBackActions();
        });
    }
    @action doNotRemind = () => {
        this.callBackActions();
    }

    @action setParams = (para={}) => {
        this.params = para;
    }

    @action setCallBackActions = (callBackActions) => {
        this.callBackActions = callBackActions;
    }
}